package com.example.demo.durable;

import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.support.CorrelationData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class DurableSender     implements RabbitTemplate.ReturnCallback,RabbitTemplate.ConfirmCallback{

    @Autowired
    private RabbitTemplate rabbitTemplate;

    public  void send(String messsage){
        rabbitTemplate.convertAndSend(DurableQueueConfig.DURABLE,messsage);
        rabbitTemplate.convertAndSend(DurableQueueConfig.NOT_DURABLE,messsage);
        rabbitTemplate.convertAndSend(DurableQueueConfig.ACK_QUEUE,messsage);
    }


    @Override
    public void returnedMessage( Message message, int replyCode, String replyText, String exchange, String routingKey) {

        System.out.println();
    }

    @Override
    public void confirm(CorrelationData correlationData, boolean ack, String cause) {
        System.out.println();
    }
}
